#include <stdio.h>
 
class Data
{
public:
	void go()
	{
		printf("Hello World!\n");
	}
	void SetData(int year, int month, int day);
public:
	int _year;
	int _month;
	int _day;
};
 
class A
{
public:
	A();
	~A();
	Data *m_data;
private:
 
};
 
A::A()
{
}
 
A::~A()
{
}
A a;
void Data::SetData(int year, int month, int day)
{
	_year = year;
	_month = month;
	_day = day;
	printf("%p\n", this);
}
 
int main()
{
	a.m_data->go();
	/*Data d1, d2;
	a.m_data = &d1;*/
	Data *d1 = new Data;
	a.m_data = d1;//通过地址赋值的方式进行内存访问
	d1->SetData(2016, 9, 25);
	printf("%d\n",a.m_data->_day);
	printf("%d\n", a.m_data->_month);
	printf("%d\n", a.m_data->_year);
	Data d2;
	d2.SetData(201, 988, 2588);
	a.m_data = &d2;
	printf("%d\n", a.m_data->_day);
	printf("%d\n", a.m_data->_month);
	printf("%d\n", a.m_data->_year);
	getchar();
}
